<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../template/taglib.jsp"%>

<jsp:include page="../template/header.jsp" />

<jsp:include page="../template/adminmenu.jsp" />

<%-- content template --%>
<jsp:include page="../template/contentheader.jsp" />
<%-- put content here --%>
<form>
	<fmt:setBundle basename="admin" />
	<c:choose>
		<c:when test="${ param['type'] == 'leavetype' }">
			<h1>
				<fmt:message key="title.leavetype" />
			</h1>
			<c:url var="InsLeavetypeurl" scope="page"
				value="/admin/adminLeavetypeDetail.jsp">
				<c:param name="name" value="" />
				<c:param name="insert" value="true" />
			</c:url>
			<a href="${InsLeavetypeurl}"><fmt:message
					key="lable.leavetype.add" /> </a>
			<br />
			<br />
			<table>
				<tr>
					<th><fmt:message key="lable.leavetypename" /></th>
					<th><fmt:message key="lable.leavetype.edit" /></th>
					<th><fmt:message key="lable.leavetype.delete" /></th>
				</tr>
				<c:forEach var="leavetype" items="${leaveType}">
					<tr>
						<td>${leavetype.name}</td>
						<td><c:url var="UpdLeavetypeurl" scope="page"
								value="/admin/adminLeavetypeDetail.jsp">
								<c:param name="name" value="${leavetype.name}" />
								<c:param name="id" value="${ leavetype.id }" />
								<c:param name="update" value="true" />
							</c:url> <a href="${UpdLeavetypeurl}"> <fmt:message
									key="lable.leavetype.edit" /> </a></td>
						<td><c:url var="DelLeavetypeurl" scope="page"
								value="/AdminLeavetypeServlet">
								<c:param name="name" value="${leavetype.name}" />
								<c:param name="id" value="${ leavetype.id }" />
								<c:param name="delete" value="true" />
								<c:param name="type" value="delete" />
							</c:url> <a href="${DelLeavetypeurl}"> <fmt:message
									key="lable.leavetype.delete" /> </a></td>
					</tr>
				</c:forEach>
			</table>
		</c:when>
		<c:when test="${ param['type'] == 'staff' }">
			<h1>
				<fmt:message key="title.staff" />
			</h1>
			<c:url var="InsStaffurl" scope="page" value="/AdminStaffServlet">
				<c:param name="insert" value="true" />
			</c:url>
			<a href="${InsStaffurl}"> <fmt:message key="lable.staff.add" />
			</a>
			<br />
			<br />
			<table>
				<tr>
					<th><fmt:message key="lable.staff.username" /></th>
					<!-- <th><fmt:message key="lable.staff.userrank" />
					</th>  -->
					<th><fmt:message key="lable.staff.usertype" /></th>
					<th><fmt:message key="lable.staff.password" /></th>
					<th><fmt:message key="lable.staff.name" /></th>
					<th><fmt:message key="lable.staff.address" /></th>
					<th><fmt:message key="lable.staff.phone" /></th>
					<th><fmt:message key="lable.staff.overtime" /></th>
					<th><fmt:message key="lable.staff.edit" />&nbsp;&nbsp;&nbsp;
						<fmt:message key="lable.staff.delete" /></th>
				</tr>
				<c:forEach var="staff" items="${user}">
					<tr>
						<td>${staff.userName}</td>
						<td><c:forEach var="usertype" items="${userTypes}">
								<c:if test="${usertype.id == staff.userType}">
									<c:out value="${ usertype.name }" />
								</c:if>
							</c:forEach></td>
						<!-- <td>${staff.userrank}</td>  -->
						<td>${staff.password}</td>
						<td>${staff.name}</td>
						<td>${staff.address}</td>
						<td>${staff.phone}</td>
						<td>${staff.overTime}</td>
						<%--<td>${staff.status}</td> --%>
						<td><c:url var="UpdStaffurl" scope="page"
								value="/AdminStaffServlet">
								<c:param name="id" value="${staff.id }" />
								<c:param name="currentusertype" value="${staff.userType}" />
								<c:param name="update" value="true" />
							</c:url> <a href="${UpdStaffurl}"> <fmt:message
									key="lable.staff.edit" /> </a> &nbsp;&nbsp;&nbsp; <c:url
								var="DelStaffurl" scope="page" value="/AdminStaffServlet">
								<c:param name="id" value="${staff.id }" />
								<c:param name="type" value="delete" />
								<c:param name="delete" value="true" />
							</c:url> <a href="${DelStaffurl}"> <fmt:message
									key="lable.staff.delete" /> </a></td>
					</tr>
				</c:forEach>
			</table>
		</c:when>

		<c:when test="${ param['type'] == 'entitlement' }">
			<h1>
				<fmt:message key="title.entitlement" />
			</h1>
			<c:url var="Insleaveurl" scope="page"
				value="/admin/editEntitlement.jsp">
				<c:param name="id" value="" />
				<c:param name="name" value="" />
				<c:param name="MedicalLeave" value="" />
				<c:param name="AnnualLeave" value="" />
				<c:param name="compensationleave" value="" />
				<c:param name="insert" value="true" />
				<%--<c:param name="Delete" value="true" /> --%>

			</c:url>
			<a href="${Insleaveurl}"> <fmt:message key="lable.staff.leave" />
			</a>
			<br />
			<br />
			<table>
				<tr>
					<th><fmt:message key="label.user.id" />
					</th>
					<th><fmt:message key="label.user.name" />
					</th>
					<th><fmt:message key="label.leave.medicalLeave" />
					</th>
					<th><fmt:message key="label.leave.annualLeave" />
					</th>
					<th><fmt:message key="label.leave.compensationleave" />
					</th>
					<th><fmt:message key="label.user.Edit" />
					</th>
					<th><fmt:message key="label.user.Delete" />
					</th>
				</tr>
				<c:forEach var="LeaveEntitlement" items="${leaveEntitlement}">
					<tr>
						<td>${ LeaveEntitlement.id }</td>
						<td>${ LeaveEntitlement.name }</td>
						<td>${ LeaveEntitlement.annualLeave }</td>
						<td>${ LeaveEntitlement.medicalLeave}</td>
						<td>${ LeaveEntitlement.compensationLeave }</td>
						<td><c:url var="updurl" scope="page"
								value="/admin/editEntitlement.jsp">
								<c:param name="id" value="${LeaveEntitlement.id}" />
								<c:param name="name" value="${ LeaveEntitlement.name}" />
								<c:param name="annualLeave"
									value="${LeaveEntitlement.annualLeave}" />
								<c:param name="medicalLeave"
									value="${ LeaveEntitlement.medicalLeave}" />
								<c:param name="compensationLeave"
									value="${LeaveEntitlement.compensationLeave}" />
								<c:param name="update" value="true" />
							</c:url> <a href="${updurl}"><fmt:message key="label.user.Edit" />
						</a></td>
						<td><c:url var="delurl" scope="page"
								value="/LeaveEntitlement">
								<c:param name="id" value="${LeaveEntitlement.id}" />

								<c:param name="delete" value="true" />
								<c:param name="type" value="delete" />
							</c:url> <a href="${delurl}"><fmt:message key="label.user.Delete" />
						</a>
						</td>
					</tr>
				</c:forEach>
			</table>
		</c:when>
		<c:when test="${ param['type'] == 'hierarchy' }">
			<h1>
				<fmt:message key="title.hierarchy" />
			</h1>
			<table>
				<tr>
					<th><fmt:message key="label.hierarchyrole" />
					</th>
					<th><fmt:message key="label.hierarchyrole.manage" />
					</th>
				</tr>
				<c:forEach var="usertype" items="${userTypes}">
					<c:if test="${usertype.id != 0}">
						<tr>
							<td>${usertype.name}</td>
							<td><c:url var="ManageHierarchyRoleUrl" scope="page"
									value="/AdminManageHierarchy">
									<c:param name="name" value="${usertype.name}" />
									<c:param name="supervisorusertype" value="${usertype.id}" />
									<c:param name="manage" value="true" />
								</c:url> <a href="${ManageHierarchyRoleUrl}"> <fmt:message
										key="label.hierarchyrole.manage" /> </a></td>
						</tr>
					</c:if>
				</c:forEach>
			</table>
		</c:when>
		<c:otherwise>Welcome~</c:otherwise>
	</c:choose>
</form>


<%-- end of content template --%>

<jsp:include page="../template/footer.jsp" />